package com.ljh;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author grung
 * @Date 2021/1/26 22:23
 * @Version 1.0
 */

public class clusterTest {

    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7001));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7002));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7003));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7004));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7005));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7006));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7007));
        jedisClusterNode.add(new HostAndPort("192.168.31.199", 7008));

        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        //jcd.set("name:001","zhangfei");
        String value = jcd.get("name:001");
        System.out.println(value);
    }
}
